<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <script src="dist/echarts.min.js"></script>

<body>
    <style>
        html,
        body {
            width: 100%;
            height: 100%;
            margin: 0;
            overflow: hidden;
        }

        #main {
            width: 80%;
            height: 90%;
            background: rgba(0, 0, 0, 0);
        }
    </style>


    <div id="main"></div>

    <script type="text/javascript">
        var myChart = echarts.init(document.getElementById('main'));
        var option;

        myChart.showLoading({

            text: 'Wait Loading Chart',
            color: '#ff33cc',
            textColor: '#fff',
            maskColor: 'rgba(0,0,0,0)',
            zlevel: 5,

        });

        var items = new Array();
        var values = new Array();

        var datas = new Array();
        var floatI100 = false;

        function anaysData() {
            for (let i = 0; i < items.length; i++) {
                var d = { value: values[i], name: items[i] };
                datas[i] = d;
            }
        };


        function SetValue() {

            ue.obj.setchartitem().then(function (ReturnValue) {
                items = ReturnValue;
            });

            ue.obj.setchartvalue().then(function (ReturnValue) {
                values = ReturnValue;
            });

            ue.obj.setcharfloati100().then(function (ReturnValue) {
                floatI100 = ReturnValue;
            });

            if (floatI100) {

                for (let i = 0; i < values.length; i++) {
                    var ix = values[i] / 100;
                    values[i] = ix;
                }
            }


        }

        function SetOption() {

            option = {
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b}: {c} ({d}%)'
                },
                legend: {
                    top: '5%',
                    left: 'center',
                },
                series: [
                    {
                        type: 'pie',
                        radius: ['30%', '50%'],
                        avoidLabelOverlap: false,
                        // itemStyle: {
                        //     borderRadius: 10,
                        //     borderColor: '#fff',
                        //     borderWidth: 2
                        // },
                        label: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            label: {
                                show: true,
                                fontSize: '40',
                                fontWeight: 'bold'
                            }
                        },
                        data: datas
                    }
                ]

            };

            window.addEventListener("resize", function () {
                myChart.resize();
            })
        }

        setInterval(function () {
            SetValue();
            anaysData();
            SetOption();

            myChart.setOption(option);
            myChart.hideLoading();
        }, 1000);

    </script>

</body>

</head>